#include<stdio.h>
#define N 15

void Sort(int *nums,int i,int j,int len) {
    int d[100];
    if(len>2) {
        Sort(nums,i,(j-i)/2+i,j-i);
        Sort(nums,j,(i+len-j)/2+j,i+len-j);
        int t1 = i,t2 = j;
        int k = 0;
        while(t1<len/2+i || t2<i+len) {
            if((nums[t1]<=nums[t2] ||t2 == i+len)&&t1<len/2+i) {
                d[k++] = nums[t1];
                t1++;
            }
            if((nums[t1]>nums[t2] || t1 == len/2+i)&&t2<i+len){
                d[k++] = nums[t2];
                t2++;
            }
        }
        for(int m = 0;m<k;m++) {
            nums[i+m] = d[m];
        }
    }
    if(len==2) {
        if(nums[i]>nums[j]) {
            nums[i] = nums[j]^nums[i];
            nums[j] = nums[i]^nums[j];
            nums[i] = nums[i]^nums[j];
        }
    }
}
int main() {
    int nums[N] = {5,4,2,6,3,6,1,4,10,2,9,7,2,8,5};
    Sort(nums,0,N/2,N);
    for(int i = 0;i<N;i++) {
        printf("%d ",nums[i] );
    }
    return 0;
}